package controllers

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	"train_project/models"
)

type TestModelController struct{
	beego.Controller
}


func (c *TestModelController) Get(){
	orm.RegisterDataBase("default","mysql","root:123456@tcp(127.0.0.1:3306)/train_project?charset=utf8")
	o := orm.NewOrm()
	user  := models.User{Id: 1}
	//id, _ := o.Insert(&user)
	err := o.Read(&user)
	if err != nil{
		c.Ctx.WriteString("读取用户失败")
	}
	c.Ctx.WriteString(fmt.Sprintf("操作数据库%v", user.Name ))
}